class Response {
  // 成功响应
  static success(ctx, data = null, message = '操作成功', code = 200) {
    ctx.status = code;
    ctx.body = {
      code,
      message,
      data,
      timestamp: Date.now()
    };
  }

  // 错误响应
  static error(ctx, message = '操作失败', code = 500, errors = null) {
    const msg = errors ? message + ':' + errors : message;
    ctx.status = code;
    ctx.body = {
      code,
      message: msg,
      timestamp: Date.now()
    };
  }

  // 分页响应
  static pagination(ctx, data, pagination, message = '分页数据获取成功', code = 200) {
    ctx.status = code;
    ctx.body = {
      code,
      message,
      data,
      pagination
    };
  }
}

module.exports = Response;